package yki.paperplane.server.db.planeoperator;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import yki.paperplane.server.db.DBOperator;

public class GetSenderNameOperator extends DBOperator{

	int plane_id;
	public GetSenderNameOperator( int pid ){
		plane_id = pid;
	}
	
	@Override
	public String execute(Connection connection) throws SQLException {
		PreparedStatement statement = connection.prepareStatement( SQL_GETUSERNAMEBYID);
		statement.setInt(1, plane_id);
		ResultSet resultSet = statement.executeQuery();
		if( resultSet.first()){
			return resultSet.getString(1);
		}
		return null;
	}

}
